import http from "@/axios/http";
import workspace from "@/axios/workspace";

// 索赔单分页
const Hp_Search = (params) => {
  return http({
    method: "get",
    url: "/faultInformation/claimant/search",
    params,
  });
};

const Hp_SearchAll = (params) => {
  return http({
    method: "get",
    url: "/faultInformation/customerquality/search",
    params,
  });
};
// 获取 质量部门所有人员
const Hp_GetresponsibilityUser = () => {
  return http({
    method: "get",
    url: "/faultInformation/customerquality/getResponsibilityUser",
  });
};
// 分配负责人
const Hp_SpecifyResponsibilityUser = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/specifyResponsibilityUser",
    data,
  });
};
// 添加 客户质量表
const Hp_PutCustomerquality = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/customerquality/save",
    // headers: {
    //   "Content-Type": "application/json;charset=UTF-8",
    // },
    data,
  });
};
// 修改 客户质量表
const Hp_UpdateCustomerquality = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/update",
    // headers: {
    //   "Content-Type": "application/json;charset=UTF-8",
    // },
    data,
  });
};


const H_ClaimantDelete = (id) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/delete/" + id,
  });
};
// 获取所有部门
const Hp_GetDept = () => {
  return http({
    method: "get",
    url: "/faultInformation/customerquality/getDept",
  });
};

// 上传责任部门及原因及附件
const Hp_UploadReasonAndDept = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/uploadReasonAndDept",
    data,
  });
};
// 修改责任部门 原因 附件
const Hp_UpdateReasonAndDept = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/updateReasonAndDept",
    data,
  });
};
// 删除责任部门
// 删除
const Hp_DelreasonAnddept = (data) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/customerquality/delReasonAndDept",
    data,
  });
};

const Hp_PushFaultInformationToDeptt = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/pushFaultInformationToDept",
    data,
  });
};

// 责任部门说明

const Hp_UploadDeptRectification = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/uploadDeptRectification",
    data,
  });
};

const Hp_PutAdd = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/save",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data,
  });
};

const Hp_Attachment = (file) => {
  let formData = new FormData();
  formData.append("file", file);
  return http({
    method: "post",
    url: "/upload/uploadFile",
    headers: {
      "Content-type": "multipart/form-data", // 如果写成contentType会报错
    },
    data: formData,
  });
};

// 修改
const Hp_Updata = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/update",
    data,
  });
};

// ipu
const Hp_Ipu = (obj) => {
  return http({
    method: "put",
    url: "/faultInformation/saveIpu",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: JSON.stringify(obj),
  });
};

// 其余故障
const Hp_Other = (obj) => {
  return http({
    method: "put",
    url: "/faultInformation/saveOther",
    headers: {
      "Content-Type": "application/json;charset=UTF-8",
    },
    data: JSON.stringify(obj),
  });
};

// 提交
const Hp_Commit = (id) => {
  var data = new FormData();
  data.append("id", id);
  return http({
    method: "post",
    url: "/faultInformation/commit",
    // headers: {
    //   "Content-Type": "application/json;charset=UTF-8",
    // },
    data,
  });
};

const Hp_FormHtml = ({ id, table }) => {
  var data = new FormData();
  data.append("id", id);
  data.append("table", table);
  return http({
    method: "put",
    url: "/faultInformation/saveTable",
    data,
  });
};

// 删除
const Hp_Deldata = (id) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/del/" + id,
  });
};

// ipu 删除
const Hp_DelIpu = (id) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/delIpu/" + id,
  });
};

// 删除Other
const O_DelOther = (id) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/delOther/" + id,
  });
};

// 审批
const O_Approval = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/approval",
    data,
  });
};

// 上传处理方案
const O_UploadSolution = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadSolution",
    data,
  });
};

// 不是 0 公里 发货申请
const H_UploadShipmentRequest = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadShipmentRequest",
    data,
  });
};

// 不是 0 公里 回货记录
const H_UploadGoodsReceipt = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadGoodsReceipt",
    data,
  });
};

// 不是 0 公里 理赔记录
const H_UploadClaimant = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadClaimant",
    data,
  });
};

// 是 0 公里
const H_UploadInventoryExpenses = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadInventoryExpenses",
    data,
  });
};

// 汇总成本
const H_UploadCost = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/uploadCost",
    data,
  });
};

// 查询 客户质量费用 详情
const H_GetCustomerQuality = (id) => {
  return http({
    method: "get",
    url: "/faultInformation/getCustomerQuality/" + id,
  });
};

// 审批部门
const H_DeptComplete = (fid, did) => {
  return http({
    method: "POST",
    url: "/faultInformation/customerquality/deptComplete/" + fid + "/" + did,
  });
};

// 8d报告
const H_Upload8Dreport = (data) => {
  return http({
    method: "POST",
    url: "/faultInformation/customerquality/upload8dReport",
    data,
  });
};

// 归档
const H_Shutdown = (id) => {
  return http({
    method: "POST",
    url: "/faultInformation/customerquality/shutdown/" + id,
  });
};

const H_ClaimantGet = (id) => {
  return http({
    method: "get",
    url: "/faultInformation/claimant/search/" + id,
  });
};

const H_ClaimantSave = (data) => {
  return http({
    method: "PUT",
    url: "/faultInformation/claimant/save",
    data,
  });
};

const H_ClaimantUpdate = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/claimant/update",
    data,
  });
};

const H_ClaimantDeleteAnnex = (data) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/delete/annex",
    data,
  });
};

// 供应商反馈
const H_ClaimantFeedbackSave = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/claimant/feedback/save",
    data,
  });
};

const H_ClaimantFeedbackUpdate = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/claimant/feedback/update",
    data,
  });
};

const H_ClaimantFeedbackDeleteAnnex = (data) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/feedback/delete/annex",
    data,
  });
};

// 供应商反馈处理
const H_ClaimantFeedbackHandleSave = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/claimant/feedback/handle/save",
    data,
  });
};

const H_ClaimantFeedbackHandleUpdate = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/claimant/feedback/handle/update",
    data,
  });
};

const H_ClaimantFeedbackHandleAnnexDelete = (data) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/feedback/handle/delete/annex",
    data,
  });
};

// 付费单据
const H_ClaimantPaymentSave = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/claimant/payment/save",
    data,
  });
};

const H_ClaimantPaymentUpdate = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/claimant/payment/update",
    data,
  });
};

const H_ClaimantPaymentAnnexDelete = (data) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/payment/delete/annex",
    data,
  });
};

// 明细
const H_ClaimantDetailedSave = (data) => {
  return http({
    method: "put",
    url: "/faultInformation/claimant/detailed/save",
    data,
  });
};

const H_ClaimantDetailedUpdate = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/claimant/detailed/update",
    data,
  });
};

const H_ClaimantDetailedDelete = (id) => {
  return http({
    method: "DELETE",
    url: "/faultInformation/claimant/detailed/del/" + id,
  });
};

const H_ClaimantDetailedExport = (id) => {
  return http({
    method: "get",
    responseType: "blob", // 1.首先设置responseType对象格式为 blob:
    url: "/faultInformation/claimant/detailed/export/" + id,
  });
};



const H_Customerquality = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/sendInternalExternal",
    data,
  });
};

// 通过名称 查询 人员
const H_SearchUserByRole = (roleId) => {
  return workspace({
    method: "get",
    url: "/role/searchUserByRole/" + roleId,
    // params:{
    //   pageSize:99,
    //   pageNum:1,
    //   userName
    // }
  });
};
// 外部责任人
const H_Allocationinternaluser = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/allocationInternalUser",
    data,
  });
};

// 内部责任人
const H_Customerqualitys = (data) => {
  return http({
    method: "post",
    url: "/faultInformation/customerquality/produceUser",
    data,
  });
};


/**
* 时间 : 2025.02.24:17.36.58 
* 功能 : 
* 用途 : 
* 作者 : 村长偷包谷
**/
const H_faultInformation = () => {
  return http({
    method: "get",
    url: "/faultInformation/claimant/filter/value",
  });
};





export default {
  Hp_Search,
  Hp_SearchAll,
  Hp_GetresponsibilityUser,
  Hp_SpecifyResponsibilityUser,

  Hp_PutCustomerquality,
  Hp_GetDept,
  Hp_UploadReasonAndDept,
  Hp_PushFaultInformationToDeptt,
  Hp_UploadDeptRectification,
  H_DeptComplete,
  H_Upload8Dreport,
  H_Shutdown,

  Hp_UpdateReasonAndDept,
  Hp_DelreasonAnddept,

  Hp_PutAdd,
  Hp_Attachment,
  Hp_Updata,
  Hp_Ipu,
  Hp_Other,
  Hp_Commit,
  Hp_FormHtml,
  Hp_Deldata,
  Hp_DelIpu,
  O_DelOther,

  O_Approval,
  O_UploadSolution,

  H_UploadShipmentRequest,
  H_UploadGoodsReceipt,
  H_UploadClaimant,
  H_UploadInventoryExpenses,

  H_GetCustomerQuality,
  Hp_UpdateCustomerquality,
  H_UploadCost,

  H_ClaimantGet,
  H_ClaimantSave,
  H_ClaimantUpdate,
  H_ClaimantDeleteAnnex,

  H_ClaimantFeedbackSave,
  H_ClaimantFeedbackUpdate,
  H_ClaimantFeedbackDeleteAnnex,

  H_ClaimantFeedbackHandleSave,
  H_ClaimantFeedbackHandleUpdate,
  H_ClaimantFeedbackHandleAnnexDelete,

  H_ClaimantPaymentSave,
  H_ClaimantPaymentUpdate,
  H_ClaimantPaymentAnnexDelete,

  H_ClaimantDetailedSave,
  H_ClaimantDetailedUpdate,
  H_ClaimantDetailedDelete,
  H_ClaimantDetailedExport,

  H_ClaimantDelete,
  H_Customerquality,
  H_Allocationinternaluser,

  H_SearchUserByRole,
  H_Customerqualitys,

  H_faultInformation,
};
